/**
 * 2025/01/01 - 2025/12/31
 */
package com.snail.starter.cloud.configuration;

import com.snail.starter.cloud.i18n.I18nInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;

/**
 *
 * @author zgadmin
 * @date 2025/8/26 13:30
 *
 */
@Configuration
public class I18nAutoConfiguration {

    @Bean
    LocaleChangeInterceptor localeChangeInterceptor() {
        I18nInterceptor i18nInterceptor = new I18nInterceptor();
        i18nInterceptor.setParamName("locale");
        return i18nInterceptor;
    }

    @Bean
    LocaleResolver localeResolver() {
        SessionLocaleResolver localeResolver = new SessionLocaleResolver();
        localeResolver.setDefaultLocale(LocaleContextHolder.getLocale());
        return localeResolver;
    }

}